//
//  LFCustomNavigationController.m
//  AntFarms
//
//  Created by LF on 2017/2/23.
//  Copyright © 2017年 GG. All rights reserved.
//

#import "LFCustomNavigationController.h"

@interface LFCustomNavigationController ()

@end

@implementation LFCustomNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 设置导航栏的颜色
//    [self.navigationBar setBarTintColor:[UIColor pinkColor]];
    [self.navigationBar setBarTintColor:[UIColor whiteColor]];
    // 设置导航栏上左右item的颜色
//    self.navigationBar.tintColor = [UIColor whiteColor];
    self.navigationBar.tintColor = [UIColor lf_colorWithHexString:@"#A5BFCB"];
    // 设置标题颜色
    [self.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],
                                                 NSForegroundColorAttributeName:[UIColor blackColor]}];
    [self setNavigationBarHidden:YES animated:NO];
    self.navigationBar.hidden = YES;
    
    
}

// 打开全局的返回手势
- (BOOL)fd_prefersNavigationBarHidden {
    return YES;
}


- (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size {
    if (!color || size.width <=0 || size.height <=0) return nil;
    CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height);
    UIGraphicsBeginImageContextWithOptions(rect.size,NO, 0);
    CGContextRef context =UIGraphicsGetCurrentContext();
    CGContextSetFillColorWithColor(context, color.CGColor);
    CGContextFillRect(context, rect);
    UIImage *image =UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

// 方法2:找出黑线,再做处理:
//通过一个方法来找到这个黑线(findHairlineImageViewUnder):
- (UIImageView *)findHairlineImageViewUnder:(UIView *)view {
    if ([view isKindOfClass:UIImageView.class] && view.bounds.size.height <= 1.0) {
        return (UIImageView *)view;
    }
    for (UIView *subview in view.subviews) {
        UIImageView *imageView = [self findHairlineImageViewUnder:subview];
        if (imageView) {
            return imageView;
        }
    }
    return nil;
}

@end







